package com.meetingshow.weibo.dao;

import java.util.List;

import com.meetingshow.common.base.dao.BaseDAO;
import com.meetingshow.common.base.dao.model.QueryStruct;
import com.meetingshow.common.base.service.model.QueryResults;
import com.meetingshow.weibo.dao.model.WeiboPO;

public class WeiboDAO extends BaseDAO {
    public Integer saveWeibo(WeiboPO weiboPO) throws Exception {
        return (Integer) this.saveBaseObj(weiboPO);
    }

    public void updateWeibo(WeiboPO weiboPO) throws Exception {
        this.updateBaseObj(weiboPO);
    }

    public void removeWeibo(WeiboPO weiboPO) throws Exception {
        this.deleteBaseObj(weiboPO);
    }

    public WeiboPO loadWeiboById(Integer weiboId) throws Exception {
        return this.queryById(WeiboPO.class, weiboId);
    }
    
    public QueryResults<WeiboPO> queryWeibo(QueryStruct queryStruct) throws Exception {
        QueryResults<WeiboPO> queryResults = new QueryResults<WeiboPO>();
        List<WeiboPO> resultList = findByParameter(queryStruct);
        queryResults.setResultList(resultList);
        if (queryStruct.getFirstResultNo() != null
                && queryStruct.getResultsPerGroup() != null) {
            queryResults = queryPageInfo(queryStruct, queryResults);
        } else {
            queryResults.setTotalResultsNum(Long.valueOf(resultList.size()));
        }
        return queryResults;
    }
}
